package com.edu.exam.enums.grading;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 批注层级枚举
 * 管理批注系统中各种显示层级和堆叠顺序
 *
 * @author System
 * @version 1.0.0
 */
public enum AnnotationLayer implements BaseEnum {

    BACKGROUND("BACKGROUND", "背景层"),
    BASE("BASE", "基础层"),
    CONTENT("CONTENT", "内容层"),
    OVERLAY("OVERLAY", "覆盖层"),
    WATERMARK("WATERMARK", "水印层"),
    TEMPLATE_BACKGROUND("TEMPLATE_BACKGROUND", "模板背景"),
    GRID("GRID", "网格层"),
    GUIDELINE("GUIDELINE", "参考线层"),
    PAPER_BACKGROUND("PAPER_BACKGROUND", "纸张背景"),
    PRINT_BASE("PRINT_BASE", "打印基础"),
    ORIGINAL_CONTENT("ORIGINAL_CONTENT", "原始内容"),
    PRE_RENDER("PRE_RENDER", "预渲染"),
    STATIC_ANNOTATION("STATIC_ANNOTATION", "静态批注"),
    DYNAMIC_CONTENT("DYNAMIC_CONTENT", "动态内容"),
    INTERACTIVE_ANNOTATION("INTERACTIVE_ANNOTATION", "交互批注"),
    REAL_TIME_ANNOTATION("REAL_TIME_ANNOTATION", "实时批注"),
    TEMPORARY_ANNOTATION("TEMPORARY_ANNOTATION", "临时批注"),
    FEEDBACK("FEEDBACK", "反馈层"),
    CORRECTION("CORRECTION", "订正层"),
    COMMENT("COMMENT", "评论层"),
    DISCUSSION("DISCUSSION", "讨论层"),
    SYSTEM("SYSTEM", "系统层"),
    ADMIN("ADMIN", "管理层"),
    DEBUG("DEBUG", "调试层"),
    FLOATING("FLOATING", "浮动层"),
    POPUP("POPUP", "弹窗层"),
    MODAL("MODAL", "模态层"),
    TOOLTIP("TOOLTIP", "提示层"),
    CURSOR("CURSOR", "光标层"),
    SELECTION("SELECTION", "选择层"),
    DRAG_PREVIEW("DRAG_PREVIEW", "拖拽预览层"),
    DROP_TARGET("DROP_TARGET", "放置目标层"),
    NOTIFICATION("NOTIFICATION", "通知层"),
    ALERT("ALERT", "警告层"),
    LOADING("LOADING", "加载层"),
    PROGRESS("PROGRESS", "进度层");

    private final String code;
    private final String description;

    AnnotationLayer(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    /**
     * 根据编码查找枚举值
     *
     * @param code 业务编码
     * @return 对应的枚举值，默认返回BACKGROUND
     */
    public static AnnotationLayer fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            return BACKGROUND;
        }

        for (AnnotationLayer layer : values()) {
            if (layer.getCode().equals(code)) {
                return layer;
            }
        }
        return BACKGROUND;
    }

    /**
     * 根据描述查找枚举值
     *
     * @param description 显示描述
     * @return 对应的枚举值，null如果未找到
     */
    public static AnnotationLayer fromDescription(String description) {
        if (description == null || description.trim().isEmpty()) {
            return null;
        }

        for (AnnotationLayer layer : values()) {
            if (layer.getDescription().equals(description)) {
                return layer;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}